package cn.careerx.app.common.models;

import java.io.Serializable;

import com.avaje.ebean.EbeanServer;

/**
 * 问答结果Model
 * @author YuNingbo
 * 2015年8月26日
 */
public class LeftOrRightResult implements Serializable{

	private static final long serialVersionUID = 9066068541709314339L;
	
	private String id;
	private String userId;
	private Integer result;
	private String lorId;
	
	public static LeftOrRightResult create(){
		return new LeftOrRightResult();
	}
	
	public static LeftOrRightResult addResult(Database db, LeftOrRightResult lorR) {
		EbeanServer es = db.getDbByPartitionKey("CAREERX", "");
		int result = es.createSqlUpdate("INSERT INTO CX_LOR_RESULT (ID,LOR_ID,USER_ID,RESULT,CREATE_AT) VALUES (?,?,?,?,now())")
		  .setParameter(1, lorR.getId())
		  .setParameter(2, lorR.getLorId())
		  .setParameter(3, lorR.getUserId())
		  .setParameter(4, lorR.getResult())
		  .execute();
		if(result>0){
			return lorR;
		}else{
			return null;
		}
	}
	
	
	
	public String getId() {
		return id == null ? "" : id;
	}
	public LeftOrRightResult setId(String id) {
		this.id = id;
		return this;
	}
	public String getUserId() {
		return userId == null ? "" : userId;
	}
	public LeftOrRightResult setUserId(String userId) {
		this.userId = userId;
		return this;
	}
	public Integer getResult() {
		return result == null ? null : result;
	}
	public LeftOrRightResult setResult(Integer result) {
		this.result = result;
		return this;
	}
	public String getLorId() {
		return lorId == null ? "" : lorId;
	}
	public LeftOrRightResult setLorId(String lorId) {
		this.lorId = lorId;
		return this;
	}
}
